package com.miaosha.error;

public enum EnumError implements CommonError{
    // 通用错误类型
    PARAMETER_VALIDATION_ERROR(10001, "参数不合法"),

    // 通用错误类型
    UNKNOWN_ERROR(10002, "未知错误 "),

    USER_NOT_EXIST(20001, "用户不存在"),
    USER_LOGIN_FAILURE(20002, "用户手机号或密码不正确"),
    USER_NOT_LOGIN(20003, "用户还未登录"),

    PRODUCT_NOT_EXIST(30001, "商品不存在"),

    STOCK_NOT_ENOUGHT(40001, "库存不足");

    private int errorCode;
    private String errorMessage;

    EnumError(int errorCode, String errorMessage){
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    @Override
    public int getErrorCode() {
        return errorCode;
    }

    @Override
    public String getErrorMessage() {
        return errorMessage;
    }

    @Override
    public CommonError setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
        return this;
    }

}
